import vue from '@vitejs/plugin-vue'



export default {
    base: './',
    plugins: [vue()],
    optimizeDeps: {
        include: ['schart.js']
    },
    server: {
      proxy: {
        '/api': {
          target: 'http://localhost:6800', // Scrapyd 服务的地址
          changeOrigin: true,
          rewrite:  (path) => path.replace(/^\/api/, ''),
        //   onProxyReq: (proxyReq, req, res) => {
        //     // 处理 OPTIONS 请求，设置 CORS 头部
        //     if (req.method === 'OPTIONS') {
        //       res.setHeader('Access-Control-Allow-Origin', '*');
        //       res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
        //       res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
        //       res.sendStatus(200);
        //     }
        //   },
        //   onProxyRes: (proxyRes, req, res) => {
        //     // 确保所有响应包含 CORS 头
        //     res.setHeader('Access-Control-Allow-Origin', '*');
        //     res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
        //     res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
        //   }
        }
      }
    }
  
}